﻿/*publish time:2011-08-03 14:34:42*/
var Mall = MFP = KISSY.app("MFP");
/*publish time:2011-08-03 14:34:42*/
document.domain = (function (B) {
    var A = location.hostname.split(".");
    return A.splice((A.length - B) > 0 ? A.length - B : 0, B).join(".")
})(2);
/*publish time:2011-10-12 10:43:28*/
MFP.add("cat-direct-promo",
function (E) {
    var A = KISSY,
    C = A.DOM,
    D = A.UA.ie == 6 ? +new Date : "20110923";
    function B() {
        C.html(".j_ChaoShiTrigger", '<a class="j_CateNavLink" href="http://chaoshi.tmall.com/" hidefocus="true">\u7f51\u7edc\u8d85\u5e02<s class="chaoshi"></s></a>');
        C.show(".j_ChaoShiTrigger");
        A.IO.get("http://www.tmall.com/go/rgn/mfp2011q3/chaoshi-cat.php?t=" + D,
        function (F) {
            C.html("#J_ChaoShiCon", F);
            setTimeout(function () {
                new MFP.Category("#J_CsCategory", {
                    viewId: "J_CsPopSubCat",
                    viewCl: "pop-subcategory",
                    subViews: "div.J_SubViewItem",
                    triggers: "li.J_MenuItem",
                    view: "#J_CsPopSubCat",
                    dataUrl: "http://www.tmall.com/go/rgn/mfp2011q3/chaoshi-cat-asyn.php"
                })
            },
            100)
        })
    }
    E.CatDirectPromo = B
});
/*pub-2|2011-11-03 22:43:39*/
MFP.add("direct-promo",
function (a) {
    function n(a, c) {
        var d = a.length,
        e;
        while (d--) e = a[d],
        b.inArray(e, c) || c.push(e);
        return c
    }
    var b = KISSY,
    c = "http://delta.taobao.com/home/delivery/AllContentByPage.do?resourceIds=",
    d = "J_DirectPromo",
    e = "J_DirectPromo_",
    f = "J_DirectPromoFloatBox",
    g = "__content_results",
    h = /^https?:\/\/\S+$/i,
    i = /^https?:\/\/\S+(png|jpg|gif)$/i,
    j = window,
    k = !1,
    l = {},
    m = [];
    a.DirectPromo = {
        init: function (a) {
            var c = b.query("." + d),
            e = [],
            f;
            if (!c || c.length === 0) return;
            b.each(c,
            function (a) {
                f = a.getAttribute("data-resid"),
                f && (e.push(f), l[f] = a)
            }),
            a && (e = n(a, e)),
            this.request(e)
        },
        request: function (a, d, e) {
            var f = this,
            h = c + a.join(",") + "&t=" + +(new Date);
            b.getScript(h,
            function () {
                var a = j[g],
                b,
                c = 0;
                if (!a || a.length === 0) return;
                if (d && d > 0) for (; c < d; c++) b = a[c].content,
                b && i.test(b) && ((new Image).src = b);
                m = m.concat(a),
                f.render(e)
            })
        },
        render: function (a) {
            var c = m.length,
            d, g, h;
            while (c--) {
                d = m[c],
                h = d.id;
                if (!l[h]) {
                    g = b.get("#" + (h === a ? f : e + h));
                    if (g) l[h] = g;
                    else continue
                }
                m.splice(c, 1),
                this._fill(d)
            }
        },
        detect: function (a) {
            var c = 100,
            d = 50,
            g = 0,
            h = this;
            if (k) return;
            k = !0,
            function () {
                var i, j;
                b.each(m,
                function (c, d) {
                    i = c.id,
                    l[i] || (j = b.get("#" + (i === a ? f : e + i)), j && (l[i] = j));
                    if (l[i]) return h._fill(m.splice(d, 1)[0]),
                    !1
                }),
                m.length > 0 && ++g < d ? setTimeout(arguments.callee, c) : k = !1
            } ()
        },
        _fill: function (a) {
            var b = l[a.id],
            c = a.content,
            d = a.link,
            e;
            if (a.id == 315 && c) {
                try {
                    Tmall.SetUserAreaInfo(c)
                } catch (f) { }
                return
            }
            if (!b || !c) return;
            if (i.test(c)) e = '<img src="' + c + '" />';
            else {
                if (c == "http://tms.tms.tms") return;
                if (h.test(c)) e = '<iframe src="' + c + '" scrolling="no" frameborder="0" width="330" height="200"></iframe>',
                d = "";
                else {
                    if (a.id == 303 && c == "shanghai") {
                        try {
                            new MFP.CatDirectPromo
                        } catch (f) { }
                        return
                    }
                    e = c
                }
            }
            b.innerHTML = d ? '<a target="_blank" href="' + d + '">' + e + "</a>" : e
        }
    }
});
/*publish time:2011-08-03 14:34:42*/
MFP.add("ecpm",
function (M) {
    var S = KISSY,
    win = window,
    doc = document;
    M.ECPM = {
        getClientInfo: function (maxLen) {
            var ci = [],
            cr = "",
            ml = maxLen || 800;
            try {
                ci = ci.concat(getDynamic(), getStatic());
                cr = ci.join("&").substr(0, ml)
            } catch (err) { }
            return cr
        },
        getRequest: function (pids, callback) {
            return "http://t.alimama.com/alimama.php?callback=" + callback + "&i=" + pids + "&t=k&" + this.getClientInfo()
        },
        requestAd: function (pids, callback) {
            var os = doc.createElement("script");
            os.id = "ecpm_ad-" + pids;
            os.async = true;
            os.src = this.getRequest(pids, callback);
            doc.getElementsByTagName("HEAD")[0].appendChild(os)
        },
        getHTML: function (o, width, height) {
            if (o.html) {
                return o.html
            }
            if (o.adboardtype == "txtlink") {
                o.html = '<a href="' + o.clickurl + '" target="_blank">' + o.title + "</a>";
                return o.html
            }
            var r = o.imgsrc.split("?")[0];
            if (typeof height === "undefined") {
                height = "auto"
            }
            if (typeof width === "undefined") {
                width = "auto"
            }
            if (r.lastIndexOf(".swf") == r.length - 4) {
                var flashvars = "swfsrc=" + encodeURIComponent(o.imgsrc) + "&clickTAG=" + encodeURIComponent(o.clickurl);
                o.html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" align="middle"><param name="allowScriptAccess" value="never" /><param name="FlashVars" value="' + flashvars + '" /><param name="movie" value="http://a.alimama.cn/js/wrapper.swf" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="http://a.alimama.cn/js/wrapper.swf" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" FlashVars="' + flashvars + '" align="middle" allowScriptAccess="never" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'
            } else {
                o.html = '<a href="' + o.clickurl + '" target="_blank"><img src="' + o.imgsrc + '" width="' + width + '" height="' + height + '" border="0"/></a>'
            }
            return o.html
        },
        init: function (hookCls, callbackName) {
            hookCls = hookCls || "J_ECPM";
            callbackName = callbackName || "g_ecpm_callback";
            var hooks = S.query("." + hookCls),
            data = {},
            i,
            len = hooks.length,
            pid,
            pids = [],
            param,
            self = this;
            for (i = 0; i < len; i++) {
                param = S.unparam(hooks[i].getAttribute("data"));
                pid = param.pid;
                hooks[i].id = pid;
                data[pid] = param;
                pids.push(pid)
            }
            self.requestAd(pids.join(","), callbackName);
            win[callbackName] = function (o) {
                try {
                    var item, i, len = o.length,
                    hook, pid;
                    for (i = 0; i < len; i++) {
                        item = o[i];
                        pid = item.pid;
                        hook = S.get("#" + pid);
                        if (hook) {
                            hook.innerHTML = self.getHTML(item.ads[0], data[pid].width, data[pid].height)
                        }
                    }
                } catch (ex) { }
            }
        }
    };
    function getDynamic() {
        var cid = [],
        bd = doc.body,
        cpr = 4973,
        i;
        var cg = "",
        cna = "",
        cks = doc.cookie.split(";"),
        cre = /(^\s*)|(\s*$)/g,
        cgn,
        cgm;
        for (i = 0; i < cks.length; i++) {
            cks[i] = cks[i].replace(cre, "");
            if (cks[i].indexOf("cna=") === 0) {
                cna = cks[i].substr(4, 24);
                break
            }
        }
        for (i = 1; i <= 32; i++) {
            cgn = Math.floor(Math.random() * 16);
            if (cna && i <= cna.length) {
                cgm = cna.charCodeAt(i - 1);
                cgn = (cgn + cgm) % 16
            }
            cg += cgn.toString(16)
        }
        cid.push("cg=" + cg);
        cid.push("ac=" + Math.floor(Math.random() * 10000));
        var ct = 0,
        cn = 16,
        cs = 0,
        cx, cy, ck, cv;
        for (i = 1; i <= cn; i++) {
            cx = Math.random();
            cy = Math.random();
            if ((Math.pow(cx, 2) + Math.pow(cy, 2)) <= 1) {
                ct++
            }
            if (i <= 12) {
                cs += cx
            }
        }
        ck = "pr" + String.fromCharCode(97 + ct);
        cv = (Math.round(cs * cpr) | ((bd ? bd.clientWidth : 0) << 16));
        cid.push(ck + "=" + cv);
        cid.push("cas=" + ck);
        cid.push("cbh=" + (bd ? bd.clientHeight : -1));
        cid.push("cbw=" + (bd ? bd.clientWidth : -1));
        cid.push("sx=0");
        cid.push("sy=0");
        return cid
    }
    function getStatic() {
        var cis = [],
        nav = navigator;
        var cs = win.screen,
        cx = 0,
        cy = 0,
        cah = 0,
        caw = 0,
        ccd = 0;
        try {
            cx = cs.width;
            cy = cs.height;
            cah = cs.availHeight;
            caw = cs.availWidth;
            ccd = cs.colorDepth
        } catch (err) { }
        cis.push("re=" + cx + "x" + cy);
        cis.push("cah=" + cah);
        cis.push("caw=" + caw);
        cis.push("ccd=" + ccd);
        cis.push("ctz=" + (-((new Date()).getTimezoneOffset() / 60)));
        cis.push("chl=" + history.length);
        cis.push("cja=" + (nav.javaEnabled() ? "1" : "0"));
        cis.push("cpl=" + (nav.plugins ? nav.plugins.length : 0));
        cis.push("cmm=" + (nav.mimeTypes ? nav.mimeTypes.length : 0));
        var cv = "-1";
        if (nav.plugins && nav.plugins.length) {
            for (var i = 0; i < nav.plugins.length; i++) {
                if (nav.plugins[i].name.indexOf("Shockwave Flash") != -1) {
                    cv = nav.plugins[i].description.split("Shockwave Flash ")[1];
                    break
                }
            }
        } else {
            if (win.ActiveXObject) {
                for (var j = 10; j >= 2; j--) {
                    try {
                        var cf = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + i + "');");
                        if (cf) {
                            cv = i + ".0";
                            break
                        }
                    } catch (err) { }
                }
            }
        }
        if (cv != "-1") {
            cv = cv.substring(0, cv.indexOf(".") + 2)
        }
        cis.push("cf=" + cv);
        var cu = "";
        if ((self.location != top.location) && doc.referrer) {
            cu = doc.referrer
        } else {
            cu = doc.location.href
        }
        var cr = doc.referrer || "";
        cis.push("u=" + encodeURIComponent(cu));
        cis.push("r=" + encodeURIComponent(cr));
        getStatic = function () {
            return cis
        };
        return cis
    }
});
/*pub-1|2012-05-04 11:48:29*/
MFP.add("category",
function (A) {
    A.THeader = function () {
        var G = KISSY,
        U = G.DOM,
        Y = G.Event,
        Z = document,
        V = "active",
        J = G.UA.ie,
        M = navigator.appVersion.indexOf("Mac") > -1,
        X = false,
        L,
        K,
        F,
        I,
        D,
        H,
        B = ['\u6309<span class="' + (M ? "cmd" : "ctrl") + ' key">Ctrl</span>+<span class="enter key">Enter</span>\u53ef\u76f4\u63a5\u641c\u7d22\u6dd8\u5b9d\u5546\u57ce\u5e97\u94fa', '\u6309 <span class="tab key">tab</span> \u5207\u6362\u641c\u7d22\u8303\u56f4'],
        Q = B[Math.floor(Math.random() * B.length)];
        function P(S) {
            if ("A" == S.tagName) {
                F.setAttribute("value", S.getAttribute("data-type"));
                D.setAttribute("action", S.href || "http://list.tmall.com/search_dispatcher.htm");
                if (!U.hasClass(S, V)) {
                    U.prepend(S, L)
                }
                G.each(L.getElementsByTagName("A"),
                function (a) {
                    U.removeClass(a, V)
                });
                U.addClass(S, V);
                I.innerHTML = S.getAttribute("data-label");
                E();
                K.focus();
                if (J) {
                    K.value = K.value
                }
            }
        }
        function W(c) {
            var a = "http://www.atpanel.com/mallsearch?",
            S = c.split(","),
            b = {
                q: S[0] || "",
                wq: S[1] || "",
                suggest: S[2] || "",
                stats: S[3] || "",
                pos: S[4] || "",
                itemid: S[5] || "",
                clickid: S[6] || "",
                page_type: S[7] || "",
                type: S[8] || "",
                combo: S[9] || "",
                active: "0",
                searchtype: "search"
            };
            a += G.param(b);
            new Image().src = a
        }
        function E() { }
        function T() {
            var a, d = Q,
            f, S = /(\?|\&)area=b2c(\&|$)/,
            c = /(\?|\&)area=shopsearch(\&|$)/;
            function b() {
                return false
            }
            function g() {
                H.query = "";
                H._dataCache = {};
                H.detach("beforeStart", b)
            }
            function e() {
                var h = document.createElement("div");
                h.className = "mallSearch-tip";
                h.innerHTML = d;
                return h
            }
            if (G.Suggest && G.Suggest.version >= 1.1) {
                H = new G.Suggest(K, "http://suggest.taobao.com/sug?area=b2c&code=utf-8", {
                    containerCls: "mall-suggest-container",
                    resultFormat: "",
                    offset: 0
                });
                a = H.container;
                E = function () {
                    var j = F.value,
                    i = H.dataSource;
                    if ("p" == j || "" == j) {
                        g();
                        d = Q;
                        if (i.search(c) > 0) {
                            H.dataSource = i.replace(c, "$1area=b2c$2")
                        } else {
                            if (i.search(S) < 0) {
                                H.dataSource = i.replace(/\?([^&]*)(&|$)/, "?area=b2c&$1$2")
                            }
                        }
                    } else {
                        if ("taobao" == j) {
                            g();
                            d = B[1];
                            var h = i.search(c) > 0 ? c : S;
                            H.dataSource = i.replace(h, "$1")
                        } else {
                            if ("s" == j) {
                                g();
                                d = B[1];
                                if (i.search(S) > 0) {
                                    H.dataSource = i.replace(S, "$1area=shopsearch$2")
                                } else {
                                    if (i.search(S) < 0) {
                                        H.dataSource = i.replace(/\?([^&]*)(&|$)/, "?area=shopsearch&$1$2")
                                    }
                                }
                            } else {
                                H.stop();
                                H.hide();
                                H.on("beforeStart", b)
                            }
                        }
                    }
                };
                H.on("updateFooter",
                function (h) {
                    if (U.text(H.content)) {
                        H.footer.appendChild(e())
                    }
                });
                H.on("itemSelect",
                function () {
                    var h = G.get(".mall-suggest-container"),
                    n = h.getElementsByTagName("li"),
                    p = 0,
                    q = "",
                    s = H.query || "",
                    t = F.value == "s" ? 2 : 1;
                    for (var l = 0,
                    r = n.length; l < r; l++) {
                        if (U.hasClass(n[l], "ks-selected")) {
                            p = l + 1;
                            q = U.text(n[l])
                        }
                    }
                    var o = s + "_" + p,
                    m = U.create('<input type="hidden" value="' + o + '" name="xl" />'),
                    u = "xl_" + t + "_suggest",
                    k = U.create('<input type="hidden" value="' + u + '" name="from" />');
                    U.append(m, D);
                    U.append(k, D);
                    var j = q + "," + s + ",0_" + p + ",suggest:0_" + p + "," + p + "," + q + "," + q + "," + t + ",5,suggest";
                    W(j)
                })
            }
        }
        function R(b, c) {
            function S(d, e) {
                var f = document.createElement("input");
                f.setAttribute("type", "hidden");
                f.setAttribute("name", d);
                f.setAttribute("value", e);
                return f
            }
            for (var a in c) {
                if (!b[a]) {
                    b.appendChild(S(a, c[a]))
                } else {
                    b[a].value = c[a]
                }
            }
        }
        function O(e, d) {
            var b, S, c, a = U.children(d);
            for (b = 0, S = a.length; b < S; ) {
                c = a[b++];
                if (c.getAttribute("data-type") == e) {
                    return c.href
                }
            }
        }
        function C() {
            setTimeout(function () {
                F.value = G.get("." + V, L).getAttribute("data-type");
                if (K.value == "") {
                    I.style.visibility = "visible"
                }
            },
            100)
        }
        function N(e) {
            function S(g) {
                return g.offsetHeight > 0 && e.offsetWidth > 0
            }
            function a(i) {
                var h = {
                    A: 1,
                    AREA: 1,
                    BUTTON: 1,
                    INPUT: 1,
                    OBJECT: 1,
                    SELECT: 1,
                    TEXTAREA: 1
                },
                g;
                return S(i) && (h[i.nodeName] || ((g = i.getAttributeNode("tabIndex")) && g.specified && g.nodeValue > -1))
            }
            var c, b, d, f = e.parentNode;
            while (e = U.prev(e)) {
                c = e.getElementsByTagName("*");
                b = c.length;
                while (b > 0) {
                    if ((d = c[--b]) && a(d)) {
                        return d
                    }
                }
                if (a(e)) {
                    return e
                }
            }
            return f && N(f)
        }
    } ()
});
/*pub-1|2012-05-03 10:02:31*/
MFP.add("slide",
function (E) {
    var D = KISSY,
    I = D.DOM,
    H = D.Event,
    F = document,
    J = "J_TsSlide",
    C = "maskLayer",
    G = "J_slideBanner",
    B = "tsSlide-trigger";
    maskItems = D.all("." + G),
    isActDirct = !!D.get("#J_ActSlideBanner"),
    defaultConfig = {
        contentCls: "tsSlide-list",
        navCls: "tsSlide-trigger",
        activeTriggerCls: "selected",
        effect: "scrollx",
        easing: "easeOutStrong",
        lazyDataType: "img-src",
        autoplay: !isActDirct
    };
    function A() {
        var K = this;
        K.mfpSlide = null;
        if (!(this instanceof A)) {
            return new A()
        }
        K._init()
    }
    D.augment(A, {
        _init: function () {
            var K = this;
            K.mfpSlide = new D.Slide("#" + J, defaultConfig);
            if (isActDirct) {
                mfpSlide.switchTo(5)
            }
            K.initMaskEvent();
            K.setRoundrect()
        },
        createMask: function (P) {
            var L = I.children(P, "a")[0],
            Q = I.children(L, "." + C)[0];
            if (!Q) {
                var M = I.children(L, "img")[0],
                O = I.height(M),
                K = I.width(M),
                N = {
                    css: {
                        top: "0",
                        left: "0",
                        width: K + "px",
                        height: O + "px",
                        position: "absolute",
                        background: "#000",
                        opacity: "0",
                        cursor: "pointer",
                        filter: "alpha(opacity=0)"
                    },
                    "class": "maskLayer"
                },
                Q = I.create("<div>", N);
                I.append(Q, L)
            }
            return Q
        },
        initMaskEvent: function () {
            var K = this;
            D.each(maskItems,
            function (M) {
                var L = {
                    fadeIn: [],
                    fadeOut: []
                };
                H.on(M, "mouseenter",
                function () {
                    var Q = I.parent(M),
                    O = I.children(Q, "." + G);
                    if (O.length <= 1) {
                        return
                    }
                    D.each(O,
                    function (S) {
                        var T = K.createMask(S);
                        I.removeClass(S, "hover");
                        I.css(T, "opacity", 0)
                    });
                    I.addClass(M, "hover");
                    for (var N = 0; N < O.length; N++) {
                        var P = O[N],
                        R = K.createMask(P);
                        if (!I.hasClass(P, "hover")) {
                            I.css(R, "opacity", 0.3)
                        }
                    }
                });
                H.on(M, "mouseleave",
                function () {
                    var O = I.parent(M),
                    N = I.children(O, "." + G);
                    if (N.length <= 1) {
                        return
                    }
                    D.each(N,
                    function (P) {
                        var Q = K.createMask(P);
                        I.css(Q, "opacity", 0)
                    })
                })
            })
        },
        setRoundrect: function () {
            var N = F.documentMode || D.UA.ie,
            K = this.mfpSlide;
            if (N < 9) {
                if (!F.namespaces.v) {
                    F.namespaces.add("v", "urn:schemas-microsoft-com:vml")
                }
                var M = F.createStyleSheet();
                M.addRule("v\\:roundrect", "behavior: url(#default#VML);display:inline-block;");
                var L = D.one("." + B).all("li");
                D.each(L,
                function (Q) {
                    var P = F.createElement("v:roundrect"),
                    O = I.hasClass(Q, defaultConfig.activeTriggerCls) ? "#b10000" : "#716564";
                    D.mix(P, {
                        arcsize: 30,
                        strokecolor: O,
                        strokeweight: "1px",
                        stroked: false,
                        fillcolor: O
                    });
                    I.css(P, {
                        position: "absolute",
                        width: "30px",
                        height: "30px",
                        antialias: true,
                        top: "0",
                        left: "0",
                        zIndex: "-1"
                    });
                    I.append(P, Q);
                    I.css(Q, {
                        background: "none"
                    })
                });
                K.on("beforeSwitch",
                function (O) {
                    D.each(L,
                    function (Q, P) {
                        I.children(Q)[0].fillcolor = (P == O.toIndex ? "#b10000" : "#716564")
                    })
                })
            }
        }
    });
    E.Slide = A
});
/*pub-2|2011-11-03 10:38:54*/
MFP.add("category",
function (a) {
    function n(a, d) {
        var e = this;
        if (e instanceof n) e.container = b.get(a),
        e.config = b.merge(m, d || {}),
        e.config.viewer = document.getElementById(d.viewId),
        e.triggers = c.query(d.triggers, e.container),
        e._init();
        else return new n(a, d)
    }
    function o(a, b) {
        for (var c = 0; c < a.length; c += 1) if (a[c] === b) return c;
        return -1
    }
    var b = KISSY,
    c = b.DOM,
    d = b.Event,
    e = document,
    f = b.UA.ie == 6,
    g = "selected",
    h = "hidden",
    i = "DIV",
    j = "mouseenter",
    k = "mouseleave",
    l = "click",
    m = {
        hideDelay: .2,
        view: null,
        viewCl: "",
        subViews: null,
        triggers: null,
        dataUrl: null
    },
    p = {
        _msxmls: ["Microsoft.XMLHTTP", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP"],
        init: function (a, b) {
            this.timer_timeout = null,
            this.timer_state_watch = null,
            this.url = a,
            this.obj = {},
            this.createXhrObject(),
            this.send(),
            this.timeout = 100,
            this.success = b,
            this.fail = function () { },
            this.abort = function () { }
        },
        createXhrObject: function () {
            var a, b;
            try {
                this.obj = new XMLHttpRequest
            } catch (c) {
                for (b = 0; b < this._msxmls.length; ++b) try {
                    this.obj = new ActiveXObject(this._msxmls[b]);
                    break
                } catch (d) { }
            } finally {
                return a
            }
        },
        send: function () {
            this.obj.open("GET", this.url, !0),
            this.beginStateWatch(),
            this.obj.send(null)
        },
        beginStateWatch: function () {
            var a = this.obj,
            b = this;
            this.timeout && (this.timer_timeout = setTimeout(function () {
                a.abort(),
                clearTimeout(b.timer_timeout),
                b.timer_timeout = null,
                b.onAbort()
            },
            this.timeout * 1e3)),
            this.timer_state_watch = setInterval(function (a) {
                return function () {
                    a.handleReadyState()
                }
            } (this), 10)
        },
        handleReadyState: function () {
            var a = this.obj;
            a.readyState === 4 && a.status == 200 ? (this.timer_timeout && (clearTimeout(this.timer_timeout), this.timer_timeout = null), clearInterval(this.timer_state_watch), this.timer_state_watch = null, this.onSuccess()) : a.readyState === 4 && this.onFail()
        },
        onSuccess: function () {
            this.success(this.obj)
        },
        onAbort: function () {
            this.abort(this.obj)
        },
        onFail: function () {
            this.fail(this.obj)
        }
    };
    b.mix(n.prototype, {
        switchTo: function (a) {
            var d = this,
            e = d.triggers,
            f = d.subViews;
            b.each(e,
            function (a) {
                c.removeClass(a, g)
            }),
            c.addClass(d.triggers[a], g),
            b.each(f,
            function (a) {
                c.addClass(a, h)
            }),
            c.removeClass(f[a], h)
        },
        show: function () {
            var a = this;
            a.container.style.zIndex = 20,
            c.removeClass(a.viewer, h),
            a.resetPostion()
        },
        resetPostion: function () {
            var a = this.triggers[this.config.idx],
            b = c.offset(a),
            d = c.offset(this.container),
            e = c.height(a),
            f = c.height(this.viewer),
            g = c.width(a),
            h = c.viewportHeight(),
            i = c.scrollTop(),
            j = h - f - (b.top - i),
            k = Math.abs(b.top - i - d.top),
            l = h - (b.top - i),
            m = b.top - d.top;
            if (j <= 0) {
                j = Math.abs(j);
                var n = 20;
                if (l > e) {
                    var o = l - e;
                    o > n ? m = m - j - n + 7 : m -= j
                } else m = m - j + n + l + 20
            }
            m < 30 && (m = 30),
            this.viewer.style.top = m + "px"
        },
        hide: function () {
            var a = this,
            d = a.triggers;
            a.container.style.zIndex = 15,
            b.each(d,
            function (a) {
                c.removeClass(a, g)
            }),
            c.addClass(a.viewer, h)
        },
        getViewerData: function (c) {
            var d = this;
            if (d.viewer = b.get("#" + d.config.viewId)) {
                d._initSubView();
                if ("hidden" == d.status) return;
                d.switchTo(d.config.idx),
                d.show(),
                d.config.getting = !0
            }
            if (d.config.getting) return;
            p.init(c,
            function (b) {
                d.config.viewer = b.responseText,
                d._initView();
                if ("hidden" == d.status) return;
                a.DirectPromo.render(),
                d.switchTo(d.config.idx),
                d.show()
            }),
            d.config.getting = !0
        },
        _init: function () {
            var a = this,
            c = a.config;
            b.each(a.triggers,
            function (b) {
                d.on(b, j,
                function (c) {
                    c.halt();
                    var d = o(a.triggers, b);
                    a.config.idx = d,
                    a.status = "visible";
                    if (!a.viewer) {
                        if (!a.config.viewer) {
                            a.getViewerData(f ? a.config.dataUrl + "?t=" + +(new Date) : a.config.dataUrl);
                            return
                        }
                        a._initView()
                    }
                    a.showTimer && clearTimeout(a.showTimer),
                    a.showTimer = setTimeout(function () {
                        a.hideTimer || (a.switchTo(d), a.show())
                    },
                    a.config.hideDelay * 1e3),
                    a.hideTimer = clearTimeout(a.hideTimer)
                }),
                d.on(b, k,
                function (b) {
                    a.status = "hidden",
                    a.showTimer && clearTimeout(a.showTimer);
                    if (a.hideTimer) return;
                    a.hideTimer = setTimeout(function () {
                        a.hide(),
                        a.hideTimer = clearTimeout(a.hideTimer)
                    },
                    a.config.hideDelay * 1e3)
                })
            })
        },
        _initView: function () {
            var a = this,
            c = a.config,
            d = b.DOM;
            a.viewer || ((a.viewer = b.get("#" + a.config.viewId)) || (a.viewer = e.createElement(i), d.attr(a.viewer, "id", c.viewId), d.addClass(a.viewer, "hidden " + c.viewCl), a.viewer.innerHTML = c.viewer, a.container.appendChild(a.viewer)), a._initSubView())
        },
        _initSubView: function () {
            var a = this,
            e = 0;
            a.subViews = c.query(a.config.subViews, a.container),
            b.each(a.subViews,
            function (b) {
                var e = c.query("dl.J_HotMenuItem", b),
                f = c.query("div.J_HotView", b),
                g;
                d.on(b, j,
                function () {
                    a.hideTimer = clearTimeout(a.hideTimer),
                    a.selectedSubView = this
                }),
                d.on(b, k,
                function () {
                    a.hideTimer = setTimeout(function () {
                        a.hide(),
                        a.hideTimer = clearTimeout(a.hideTimer)
                    },
                    a.config.hideDelay * 1e3)
                })
            })
        }
    }),
    a.Category = n
});
/*publish time:2011-09-06 15:39:22*/
var S = KISSY,
DOM = S.DOM,
Event = S.Event,
doc = document;
function TmallMask(A) {
    this.config = {
        content: A.contentID,
        itemsCls: A.itemsCls || "j_MaskItem",
        maskCls: A.maskCls || "maskLayer",
        maskColor: A.maskColor || "#000",
        activeOpacity: A.activeOpacity || 0.3,
        defaultOpacity: A.normalOpacity || 0,
        speed: A.speed || 0.2
    };
    this._init()
}
TmallMask.prototype = {
    _init: function () {
        var A = this,
        B = S.all("#" + A.config.content + " ." + A.config.itemsCls);
        S.each(B,
        function (D) {
            var C = {};
            Event.on(D, "mouseenter",
            function () {
                var H = DOM.parent(D),
                F = DOM.children(H, "." + A.config.itemsCls);
                if (F.length <= 1) {
                    return
                }
                S.each(F,
                function (J) {
                    var K = A.createMask(J);
                    DOM.removeClass(J, "hover");
                    DOM.css(K, "opacity", 0)
                });
                DOM.addClass(D, "hover");
                for (var E = 0; E < F.length; E++) {
                    var G = F[E],
                    I = A.createMask(G);
                    if (!DOM.hasClass(G, "hover")) {
                        DOM.css(I, "opacity", 0.3)
                    }
                }
            });
            Event.on(D, "mouseleave",
            function () {
                var F = DOM.parent(D),
                E = DOM.children(F, "." + A.config.itemsCls);
                if (E.length <= 1) {
                    return
                }
                S.each(E,
                function (G) {
                    var H = A.createMask(G);
                    DOM.css(H, "opacity", 0)
                })
            })
        })
    },
    createMask: function (F) {
        var C = this;
        var G = DOM.children(F, "." + this.config.maskCls)[0];
        if (!G) {
            var B = DOM.children(F, "img")[0],
            E = DOM.height(B),
            A = DOM.width(B),
            D = {
                css: {
                    top: "0",
                    left: "0",
                    width: A + "px",
                    height: E + "px",
                    position: "absolute",
                    background: C.config.maskColor,
                    opacity: C.config.defaultOpacity,
                    cursor: "pointer",
                    filter: "alpha(opacity=" + C.config.defaultOpacity + ")"
                },
                "class": "maskLayer"
            },
            G = DOM.create("<div>", D);
            DOM.append(G, F)
        }
        return G
    }
};
/*pub-1|2012-05-03 10:02:31*/
MFP.add("brand-promo",
function (G) {
    var C = KISSY,
    D = C.DOM,
    F = "J_BrandAdvice",
    B = "http://ald.taobao.com/special/recommendTmallIndexBrand.htm",
    A = "http://ald.taobao.com/special/tmallIndexBrandClick.htm";
    function E() {
        if (!(this instanceof E)) {
            return new E()
        }
        this.content = C.get("#" + F);
        this.init()
    }
    C.augment(E, {
        init: function () {
            var H = this,
            I = B + "?callback=__setBrandPromo&t=" + +new Date;
            if (!H.content) {
                return
            }
            window.__setBrandPromo = H.render;
            C.getScript(I,
            function () {
                C.ready(function (J) {
                    H.addClickEvent()
                })
            })
        },
        getNick: function () {
            var H;
            if (C.get(".j_UserNick")) {
                H = D.text(".j_UserNick")
            }
            if (!H) {
                H = C.Cookie.get("tracknick")
            }
            H = H || -1;
            return encodeURIComponent(H)
        },
        render: function (M) {
            var N = "",
            J = "",
            Q = 0,
            I = KISSY.get("#J_BrandAdvice"),
            H = function (W) {
                if (typeof W === "undefined" || !(W instanceof Array) || W.length < 4) {
                    return false
                }
                var U = W.length,
                X = [],
                T = 0;
                for (var V = 0; V < U; V++) {
                    T = parseInt(V / 4);
                    if (typeof X[T] === "undefined") {
                        X[T] = []
                    }
                    X[T].push(W[V])
                }
                return X
            },
            R = function (X, Z) {
                var U = '<div class="brandAdvice-list">',
                a = Z ? "data-ks-lazyload-custom" : "src",
                Y = '<a href="{href}" target="_blank" class="brandAdvice-item"><span><img width="121" height="174" alt="{text}" ' + a + '="{img}"></span></a>\n';
                for (var V = 0,
                T = X.length; V < T; V++) {
                    var W = X[V];
                    U += KISSY.substitute(Y, {
                        href: W.actUrl,
                        text: W.title,
                        img: W.pictUrl
                    })
                }
                U += "</div>";
                return U
            },
            S = H(M.data);
            if (!S) {
                return
            }
            for (var L = 0,
            O = S.length; L < O; L++) {
                var P = S[L];
                if (P && P.length == 4) {
                    N += R(P, L > 0);
                    Q++
                }
            }
            J = '<span class="brandAdvice-nav"><a href="" class="slide-prev">&lt;</a><span><em id="J_BACurrentIndex">1</em>/' + Q + '</span><a href="" class="slide-next">&gt;</a></span>';
            J = D.create(J);
            D.css(I, "opacity", "0");
            D.html(I, N);
            var K = new C.Anim(I, {
                opacity: "1"
            },
            0.5).run();
            if (Q > 1) {
                D.insertBefore(J, I);
                K.on("complete",
                function () {
                    var T = new C.Carousel("#J_BASlide", {
                        hasTriggers: false,
                        contentCls: "brandAdvice-con",
                        effect: "scrollx",
                        duration: ".3",
                        easing: "easeOutStrong",
                        prevBtnCls: "slide-prev",
                        nextBtnCls: "slide-next",
                        lazyDataType: "img-src",
                        circular: true
                    });
                    T.on("beforeSwitch",
                    function (U) {
                        D.html("#J_BACurrentIndex", U.toIndex + 1)
                    })
                })
            }
            new Image().src = M.atpanelUrl
        },
        addClickEvent: function () {
            var H = this;
            Event.on(H.content, "click",
            function (K) {
                var M = K || window.event,
                L = M.target || M.srcElement,
                J = D.parent(L,
                function (N) {
                    return N.nodeName.toLowerCase() === "a"
                });
                if (J || L.nodeName.toLowerCase() === "a") {
                    var I = H.getNick();
                    new Image().src = A + "?nick=" + I
                }
            })
        }
    });
    G.BrandPromo = E
});
/*pub-1|2012-02-27 18:50:05*/
(function () {
    var C = KISSY,
    K = C.DOM,
    J = C.Event,
    G = MFP,
    I = document,
    E = "selected",
    H = "click",
    B = "scrolly",
    D, F, A = [
    function () {
        G.DirectPromo.init(["239", "240"])
    },
    function () {
        G.ECPM.init()
    },
    function () {
        new C.DataLazyload({
            mod: "manual",
            diff: 100
        })
    },
    function () {
        new G.Category("#J_AllCategory", {
            viewId: "J_AllPopSubCat",
            viewCl: "pop-subcategory",
            subViews: "div.J_SubViewItem",
            triggers: "li.J_MenuItem",
            dataUrl: 'all-cat-asyn.htm'
        });
        new G.Category("#J_3cCategory", {
            viewId: "J_3cPopSubCat",
            viewCl: "pop-subcategory",
            subViews: "div.J_SubViewItem",
            triggers: "li.J_MenuItem",
            dataUrl: "all-cat-asyn.htm"
        });
        new G.Category("#J_BeautyCategory", {
            viewId: "J_BeautyPopSubCat",
            viewCl: "pop-subcategory",
            subViews: "div.J_SubViewItem",
            triggers: "li.J_MenuItem",
            dataUrl: "all-cat-asyn.htm"
        });
        new G.Category("#J_JiaCategory", {
            viewId: "J_JiaPopSubCat",
            viewCl: "pop-subcategory",
            subViews: "div.J_SubViewItem",
            triggers: "li.J_MenuItem",
            dataUrl: "all-cat-asyn.htm"
        });
        new G.Category("#J_YiyaoCategory", {
            viewId: "J_YiyaoPopSubCat",
            viewCl: "pop-subcategory",
            subViews: "div.J_SubViewItem",
            triggers: "li.J_MenuItem",
            dataUrl: "all-cat-asyn.htm"
        })
    },
    function () {
        C.all(".j_CateNavLink").on("mouseover",
        function (O) {
            K.addClass(".pop-subcategory", "hidden")
        });
        var M = new C.Tabs("#J_CategoryTab", {
            contentCls: "tsCategory-con",
            navCls: "tsCategory-nav",
            lazyDataType: "img-src",
            activeTriggerCls: E
        });
        if (!!C.get("#J_SaleProSlide")) {
            var N = new C.Carousel("#J_SaleProSlide", {
                contentCls: "salePro-slideCon",
                effect: "scrollx",
                prevBtnCls: "sp-prevPage",
                nextBtnCls: "sp-nextPage",
                duration: 0.3,
                lazyDataType: "img-src",
                interval: 10,
                hasTriggers: false,
                circular: true,
                autoplay: true,
                easing: "easyOutStrong"
            })
        }
        var L = new C.Tabs("#J_MallNotice", {
            contentCls: "mallNotice-con",
            navCls: "mallNotice-hd",
            activeTriggerCls: E
        })
    },
    function () {
        new G.Slide()
    } ];
    for (D = 0, F = A.length; D < F; ++D) {
        A[D]()
    }
})();